
##########################################################################
# 将该项目打包成类包
# 注意！！！打包成类库之前，一定要先复制该项目，重新打包
$current=$PWD
# 获取当前用户桌面
$desktopPath = "$HOME\Desktop"

# 定义源文件夹和目标文件夹的路径
$sourceFolder = $current
$destinationFolder = $desktopPath+"\OJ-exam"
 
# 确保目标文件夹存在
if ( (Test-Path $destinationFolder) ) {
    Remove-Item -Path $destinationFolder  -Recurse -Force

    # Get-ChildItem -Path destinationFolder -File | Remove-Item
    # Remove-Item -ItemType Directory -Path $destinationFolder | Out-Null
}
New-Item -ItemType Directory -Path $destinationFolder | Out-Null
 
# 复制文件夹
Copy-Item -Path $sourceFolder -Destination $destinationFolder -Recurse -Exclude .\target

$currentFolderName = (Get-Item .).Name
Write-Host "当前文件夹名是: $currentFolderName"

Set-Location "$destinationFolder\$currentFolderName"
# 首先清理多余文件
mvn clean
Remove-Item .\.git -Force -Recurse
Remove-Item .\.gitignore
Remove-Item .\README.md
Remove-Item .\*.ps1
Remove-Item .\SQL语句试题.sql -Force -Recurse
Remove-Item .\*.txt -Force -Recurse
Remove-Item .\*.docx -Force -Recurse
Remove-Item .\LICENSE -Force -Recurse
Get-ChildItem -Directory .\src\main\java\ -Exclude OJUtils | Remove-Item -Recurse -Force
Get-Item -Path .\src\main\java\* -Exclude OJUtils -Include .\src\main\java\T1.java | Remove-Item -Recurse -Force

Set-Location $current